<template>
  <div>
    <van-search
      v-model="searchValue"
      shape="round"
      background="#4fc08d"
      placeholder="请输入搜索关键词"
    />
    <List :list="searchList"/>
  </div>
</template>


<script>
import axios from 'axios'
import List from '@/components/List'
export default {
  name: 'Search',
  data() {
    return {
      // 搜搜的值
      searchValue: '',
      // 大数据
      list: []
    }
  },
  computed: {
    // 搜索的结果
    searchList() {
      return this.list.filter(item => item.title.includes(this.searchValue))
    }
  },
  components: {
    List
  },
  created() {
    // 请求数据
    axios.get('/list').then(resp => {
      this.list = resp.data.data
    })
  }
}
</script>